package com.aaa.ssm.controller;

import com.aaa.ssm.entity.Hospital;
import com.aaa.ssm.entity.SysRole;
import com.aaa.ssm.service.impl.HospitalServiceImpl;
import com.aaa.ssm.util.Page;
import com.aaa.ssm.util.Result;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController //@Controller+@ResponseBody
@RequestMapping("hospital")
public class HospitalController extends BaseController{
    @Resource
    private HospitalServiceImpl hospitalService;

    /**
     * 省份下的医院
     * @param hospProvince
     * @return
     */
    @GetMapping("queryAll")
    public Result  queryAll(Integer hospProvince){
        return success(hospitalService.queryAll(hospProvince));
    }
    /**
     * 市下的医院
     * @param hospCity
     * @return
     */
    @GetMapping("queryByCity")
    public Result  queryByCity(Integer hospCity){
        return success(hospitalService.queryByCity(hospCity));
    }

    /**
     * 分页查询
     * @param page
     * @return
     */
    @PostMapping("queryByPage")
    @ResponseBody
    public Result queryByPage(@RequestBody Page<Hospital> page){
        return success(hospitalService.queryByPage(page));
    }

    /**
     * 查询所有
     * @param hospital
     * @return
     */
    @GetMapping("queryByParam")
    public Result queryByParam(@RequestBody Hospital hospital){
        List<Hospital> patientList=hospitalService.queryByParam(hospital);
        return success(patientList);
    }

    /**
     * 通过Id查找
     * @param hospId
     * @return
     */
    @GetMapping("queryById")
    public Result queryById(Integer hospId){
        return success(hospitalService.queryById(hospId));
    }

    /**
     * 添加
     * @param hospital
     * @return
     */
    @PutMapping("add")
    public Result add(@RequestBody Hospital hospital){
        return success(hospitalService.add(hospital));
    }

    /**
     * 更新
     * @param hospital
     * @return
     */
    @PutMapping("update")
//    @ResponseBody
    public Result update(@RequestBody Hospital hospital){
        return success(hospitalService.update(hospital));
    }

    /**
     * 删除
     * @param hospId
     * @return
     */
    @DeleteMapping("delete")
//    @ResponseBody
    public Result delete(Integer hospId){
        return  success(hospitalService.delete(hospId));
    }
    @GetMapping("queryByHospital")
    public Result queryByHospital( Integer hospId){
        return success(hospitalService.queryByHospital(hospId));
    }
}
